Spread Windows Forms 10.0 Product Documentation
SortRange(Int32,Int32,Int32,Int32,Boolean,SortInfo[]) Method
Example 


Index of the starting row of the block of cells to sort
Index of the starting column of the block of cells to sort
Number of rows in the block of cells
Number of columns in the block of cells
Whether to sort by rows (or by columns)
SortInfo object with sort criteria and how to perform sort
Sorts a range of cells on this sheet in the data model.
Syntax
'Declaration
 
Public Function SortRange( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal rowCount As Integer, _
   ByVal columnCount As Integer, _
   ByVal byRows As Boolean, _
   ByVal sortInfo() As SortInfo _
) As Boolean
'Usage
 
Dim instance As SheetView
Dim row As Integer
Dim column As Integer
Dim rowCount As Integer
Dim columnCount As Integer
Dim byRows As Boolean
Dim sortInfo() As SortInfo
Dim value As Boolean
 
value = instance.SortRange(row, column, rowCount, columnCount, byRows, sortInfo)
public bool SortRange( 
   int row,
   int column,
   int rowCount,
   int columnCount,
   bool byRows,
   SortInfo[] sortInfo
)

Parameters

row
Index of the starting row of the block of cells to sort
column
Index of the starting column of the block of cells to sort
rowCount
Number of rows in the block of cells
columnCount
Number of columns in the block of cells
byRows
Whether to sort by rows (or by columns)
sortInfo
SortInfo object with sort criteria and how to perform sort
Remarks

This method is for unbound data only. This method sorts the data in a range of cells by moving the data around in the data model and moving the cell-level styles along with it. This method is not intended for bound data, as it moves data (not necessarily by entire row or column) and has the effect of of moving the data around in the data source.

If byRows is true, the range is sorted by rows; if byRows if false, the range is sorted by columns.

With the sortInfo array, you can specify multiple criteria for sorting the data. This method gives you the ability to sort (or arrange) data in a smaller subset than entire rows or columns in a sheet. For more information, refer to the SortInfo object.

For bound data, use the SortColumns or SortRows methods. For a discussion of sorting, refer to Managing Sorting of Rows of User Data.

Example
FarPoint.Win.Spread.SortInfo[] sort = new FarPoint.Win.Spread.SortInfo[1];
sort[0] = new FarPoint.Win.Spread.SortInfo(0, true, System.Collections.Comparer.Default);
fpSpread1.ActiveSheet.SetValue(0, 0, "C");
fpSpread1.ActiveSheet.SetValue(1, 0, "A");
fpSpread1.ActiveSheet.SetValue(2, 0, "E");
fpSpread1.ActiveSheet.SetValue(3, 0, "B");
fpSpread1.ActiveSheet.SetValue(0, 1, "3");
fpSpread1.ActiveSheet.SetValue(1, 1, "5");
fpSpread1.ActiveSheet.SetValue(2, 1, "1");
fpSpread1.ActiveSheet.SetValue(3, 1, "2");
fpSpread1.ActiveSheet.SortRange(0, 0, 4, 2, true, sort);
Dim sort(1) As FarPoint.Win.Spread.SortInfo
sort(0) = New FarPoint.Win.Spread.SortInfo(0, True, System.Collections.Comparer.Default)
FpSpread1.ActiveSheet.SetValue(0, 0, "C")
FpSpread1.ActiveSheet.SetValue(1, 0, "A")
FpSpread1.ActiveSheet.SetValue(2, 0, "E")
FpSpread1.ActiveSheet.SetValue(3, 0, "B")
FpSpread1.ActiveSheet.SetValue(0, 1, "3")
FpSpread1.ActiveSheet.SetValue(1, 1, "5")
FpSpread1.ActiveSheet.SetValue(2, 1, "1")
FpSpread1.ActiveSheet.SetValue(3, 1, "2")
FpSpread1.ActiveSheet.SortRange(0, 0, 4, 2, True, sort)
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

SheetView Class
SheetView Members

 

 


Copyright © GrapeCity, inc. All rights reserved.